﻿using System;
using System.Data;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using socialnexus.classes.models;

namespace socialnexus.classes.pages
{
    public class AuthenticatedUserPage : System.Web.UI.Page
    {
        protected void Page_Init(object sender, EventArgs e)
        {
            RequireAuthentication();
        }

        public void RequireAuthentication()
        {
            if (!IsAuthenticated())
            {
                Response.Redirect("~/");
                Response.Close();
            }
        }

        public bool IsAuthenticated()
        {
            return Session["user"] != null;
        }

        public SiteUser GetUser()
        {
            return (SiteUser)Session["user"];
        }
    }
}
